//
//  PPShowNoDataView.m
//  PPCheckTool
//
//  Created by BenJim on 2019/4/5.
//

#import "PPShowNoDataView.h"

@interface PPShowNoDataView ()


@end


@implementation PPShowNoDataView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self configViews];
    }
    return self;
}


- (void) configViews{
    
    [self addSubview:self.logoView];
    
    [self addSubview:self.toastLab];
    
    [self addSubview:self.loadBtn];
    
    self.toastLab.translatesAutoresizingMaskIntoConstraints = NO;
    
    self.loadBtn.translatesAutoresizingMaskIntoConstraints = NO;
    
    
    // center _toastLab horizontally in self
    [self addConstraint:[NSLayoutConstraint constraintWithItem:_toastLab attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]];
    
    // center _toastLab vertically in self
    [self addConstraint:[NSLayoutConstraint constraintWithItem:_toastLab attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0]];
    
    
    
    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_loadBtn]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_loadBtn)]];
    
    // align _loadBtn from the top and bottom
    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_loadBtn]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_loadBtn)]];
    
    
}


- (UIImageView *)logoView {
    if (!_logoView) {
        _logoView = [[UIImageView alloc]init];
    }
    return _logoView;
}

- (UILabel *)toastLab {
    if (!_toastLab) {
        _toastLab = [[UILabel alloc]init];
        _toastLab .textColor = [UIColor blackColor];
        _toastLab.font = [UIFont systemFontOfSize:15];
        _toastLab.text = @"点击重试";
        _toastLab.backgroundColor = [UIColor redColor];
    }
    return _toastLab;
}

- (UIButton *)loadBtn{
    if (!_loadBtn) {
        _loadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _loadBtn.backgroundColor = [UIColor clearColor];
    }
    return _loadBtn;
}

@end
